@import "var.less";
@shadowColor: rgba(0,0,0, 0.3);
@menuHeight: 1rem;
@menuBlank:0.3rem;//菜单的间距
@menuBackground: #F5F7F7;
//@menuLiColor:rgba(255,255,255,0.8);
@menuLifrontColor:#CCE8FE;
@liBorderColor: #B6CCDE;
@listColor: #EFF0EF;
@listBorderColor: #979797;

@itemHeight: 1.1rem;
@itemIconWidth: 1.5rem;
@itemHoverBorderColor: #78AEE5;
@itemHoverBackgroundColor: #78AEE5;

@positiveBuffer: 3rem;
@reverseBuffer: 1rem;
@bufferColor: transparent;

@defaultZindex:0;//在基准量的基础上增加的数量值

menu.oc-menu {
	position: relative;
	list-style: none;
	height: @menuHeight;
	ul{
		z-index: 10;
	}
	// 菜单被操作时才允许所有li的悬停动作
	&.focus li:hover > ul {
		display: block;
	}
	&:before {
		content: "";
		display: none;
		position: fixed;
		width: 100%;
		height: 100%;
		z-index: 10 + @defaultZindex;
	}
	&.focus:before {
		display: block;
	}

	li {
		position: relative;
	}
	// Menu的按钮
	> li{
		cursor: default;
		float: left;
		height: @menuHeight;
		line-height: @menuHeight - 0.1rem;
		padding:0 @menuBlank;
		z-index: 11 + @defaultZindex;
		box-sizing: border-box;
		border: 1px solid transparent;
		&:hover {
			background-color: @menuLifrontColor;
			border: 1px solid @liBorderColor;
		}

		// 所有菜单
		ul {
			display: none;
			position: absolute;
			border: 1px solid @listBorderColor;
			top:0;
			left: 100%;
			margin-left: -1px;//解决边框定位偏移的1px
			padding: 2px;
			background: @listColor;
			box-shadow: 4px 4px 2px -2px @shadowColor;
			li {
				list-style: none;
				padding: 1px @itemIconWidth;
				box-sizing: border-box;
				height: @itemHeight;
				min-width: 4em;
				border:  1px solid transparent;

				// Item Buffer When hover
				&:hover:after{
					content: "";
					display: block;
					position: absolute;
					left: 0;
					height: 0.4rem;
					top:100%;
					width: 100%;
					z-index: 2;
				}
				// Sub icon
				&.sub:before {
					content: "";
					position: absolute;
					display: block;
					width: 0;
					height: 0;
					border: 0.2rem solid;
					border-color: transparent transparent transparent #000;
					top: 0.3rem;
					right: 0.2rem;
				}

				// Item was wraped by button
				a {
					font: inherit;
					text-align: left;
					border: none;
					background: transparent;
					white-space: nowrap; // 为了让按钮里的文本不换行
					cursor: default; // button默认为手型指针
					&::-moz-focus-inner {
						padding:0;
						border:0
					}
					&:after {
						content: "";
						position: absolute;
						top:0;
						left: 0;
						right: 0;
						bottom: 0;
					}
				}
				// Offset when sub ul dispeared.
				> ul{
					margin-top: -2px;
					margin-left: -2px;
				}
				&:hover {
					background: @itemHoverBackgroundColor;
					z-index: 1;
				}
			}
		}
		// 菜单缓冲区
		ul:before {
			content: "";
			background: @bufferColor;
			position: absolute;
			top: 0;
			left: -@reverseBuffer;
			right: -@positiveBuffer;
			bottom: -@positiveBuffer;
		}
		// 第一层菜单的特殊处理
		> ul {
			top: 100%;
			left: 0;
		}
	}
	hr{
		width: auto;
		position: relative;
		z-index: -1;
		height:1px;
		border-width:0;
		background-color: rgb(215, 215, 215);//hr的颜色，这里颜色比较浅，和一般的hr不一样，特此没有新建变量存放该颜色
		margin-left: 1.4rem;
		margin-top: 0.1rem;
		margin-bottom: 0.1rem;
	}
}

@keyframes fadeIn {
	from {
		opacity: 0.3;
	}
	to {
		opacity: 1;
	}
}
.sub:hover > ul {
	display: block;
	animation: fadeIn 0.3s;
}
